`timescale 1ns / 1ps

module pc_mux (
  input         jump,
  input  [63:0] pc_4,
  input  [63:0] alu_res,
  input         predict_jump_if,
  input         predict_jump_exe,
  input  [63:0] EXE_pc,
  input         switch_mode,
  input  [63:0] pc_csr,
  input  [63:0] pc_target_if,
  input         stall,
  output reg [63:0] npc
);
wire predict_wrong = (~jump && predict_jump_exe);  // 预测不跳实际跳转
wire predict_wrong2 = (jump && ~predict_jump_exe); // 预测跳转实际不跳

always @(*) begin
    // if(switch_mode) npc=pc_csr;
    if(switch_mode) npc = pc_csr;
    else if(jump) npc = alu_res;
    // else if(predict_jump_if) npc=pc_target_if;
    // else if(predict_wrong) npc = EXE_pc+4;
    else npc=pc_4;
end

// always @(posedge clk) begin
//     if(!lock & jump & !predict_jump_exe) lock = 1;
//     else if(lock & if_stall) lock = 0;
// end

endmodule
